home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0050_Available Drives.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  1KB  |  48 lines

  1. {
  2. KENT BRIGGS
  3.  
  4. > Does anyone know how to check if a drive is valid Without accessing
  5. > it to see? For example, if the available drives on a system are: A, B,
  6. > C, E. How do you check if drive A is installed Without having the
  7. > floppy drive lights go on. I use TP6, so if you include a sample code,
  8. > could you make it compatible With it.
  9. }
  10.  
  11. Program Show_drives;
  12.  
  13. Uses
  14.   Dos;
  15.  
  16. Var
  17.   Drv : Array [1..3] of Byte;
  18.  
  19. Procedure ReportDrives;
  20. Var
  21.   Regs    : Registers;
  22.   Count   : Integer;
  23.   DrvList : String[26];
  24.   Fcb     : Array [1..37] of Byte;
  25. begin
  26.   DrvList := '';
  27.   For Count := 1 to 26 do         {Try drives A..Z}
  28.   begin
  29.     Drv[1]  := Count + 64;         {A=ASCII 65, etc}
  30.     Drv[2]  := Ord(':');
  31.     Drv[3]  := 0;
  32.     Regs.AX := $2906;          {Dos Function 29h = Parse Filename}
  33.     Regs.SI := Ofs(Drv[1]);    {Point to drive String}
  34.     Regs.DI := Ofs(Fcb[1]);    {Point to File Control Block}
  35.     Regs.DS := DSeg;
  36.     Regs.ES := DSeg;
  37.     MsDos(Regs);               {Dos Interrupt}
  38.     if Regs.AL <> $FF then
  39.       DrvList := DrvList + Chr(Count + 64);
  40.   end;
  41.   Writeln('Available drives = ', DrvList);
  42. end;
  43.  
  44. begin
  45.   ReportDrives;
  46. end.
  47.  
  48.